/*
 * Copyright (c) 2019 DawnFramework. All Rights Reserved.
 * Licensed under the MIT (LICENSE) license.
 */

package org.dawn.common.apiclient.json;

import java.lang.reflect.Type;
import java.util.List;

/**
 * @author Willard Hu on 2019-04-28.
 */
public interface Json {
    /**
     * Serialize the given Java object into JSON string.
     *
     * @param obj Object
     * @return String representation of the JSON
     */
    String serialize(Object obj);

    /**
     * Deserialize the given JSON string to Java object.
     *
     * @param <T>        Type
     * @param body       The JSON string
     * @param dataType   The type to deserialize into
     * @return The deserialized Java object
     */
    <T> T deserialize(String body, Type dataType);

    /**
     * Deserialize the given JSON string to Java list.
     *
     * @param <T>        Type
     * @param body       The JSON string
     * @param clz        The type to deserialize into
     * @return The deserialized Java list
     */
    <T> List<T> deserializeArray(String body, Class<T> clz);
}
